<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>数据导入和导出 | Introduction</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../home/part2/MySQL高级.html" />
    
    
    <link rel="prev" href="../../home/part1/5.DQL操作：数据查询.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="2.6"
        data-chapter-title="数据导入和导出"
        data-filepath="home/part1/6.数据导入和导出.md"
        data-basepath="../.."
        data-revision="Sun Oct 21 2018 16:32:53 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="home/MySQL介绍.html">
            
                
                    <a href="../../home/MySQL介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        MySQL介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2" data-path="home/part1/MySQL基础.html">
            
                
                    <a href="../../home/part1/MySQL基础.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Mysql基础
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="home/part1/1.MySQL基础操作.html">
            
                
                    <a href="../../home/part1/1.MySQL基础操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        MySQL基础操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="home/part1/2.MySQL数据类型.html">
            
                
                    <a href="../../home/part1/2.MySQL数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        MySQL数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="home/part1/3.MySQL建库建表.html">
            
                
                    <a href="../../home/part1/3.MySQL建库建表.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        MySQL建库建表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="home/part1/4.DML操作：增,删,改.html">
            
                
                    <a href="../../home/part1/4.DML操作：增,删,改.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        DML操作：增,删,改
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="home/part1/5.DQL操作：数据查询.html">
            
                
                    <a href="../../home/part1/5.DQL操作：数据查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        DQL操作：数据查询
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.6" data-path="home/part1/6.数据导入和导出.html">
            
                
                    <a href="../../home/part1/6.数据导入和导出.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        数据导入和导出
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="home/part2/MySQL高级.html">
            
                
                    <a href="../../home/part2/MySQL高级.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        MySQL高级
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="home/part2/1.MySQL的多表联查.html">
            
                
                    <a href="../../home/part2/1.MySQL的多表联查.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        MySQL的多表联查
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="home/part2/2.MySQL的事务处理.html">
            
                
                    <a href="../../home/part2/2.MySQL的事务处理.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        MySQL的事务处理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="home/part2/3.MySQL的视图及其它.html">
            
                
                    <a href="../../home/part2/3.MySQL的视图及其它.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        MySQL的视图及其它
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="home/part2/4.MySQL的触发器.html">
            
                
                    <a href="../../home/part2/4.MySQL的触发器.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        MySQL的触发器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="home/part2/6.MySQL日志及数据恢复.html">
            
                
                    <a href="../../home/part2/6.MySQL日志及数据恢复.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        MySQL日志及数据恢复
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="home/part2/7.慢查询及sql优化.html">
            
                
                    <a href="../../home/part2/7.慢查询及sql优化.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        慢查询及sql优化
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="home/part3/Python连接MySQL.html">
            
                
                    <a href="../../home/part3/Python连接MySQL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        Python连接MySQL
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="home/part3/1.CRUD.html">
            
                
                    <a href="../../home/part3/1.CRUD.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        CRUD
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Introduction</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x6570;&#x636E;&#x5BFC;&#x5165;&#x548C;&#x5BFC;&#x51FA;">&#x6570;&#x636E;&#x5BFC;&#x5165;&#x548C;&#x5BFC;&#x51FA;</h1>
<hr>
<ul>
<li><h3 id="&#x6570;&#x636E;&#x5BFC;&#x51FA;">&#x6570;&#x636E;&#x5BFC;&#x51FA;</h3>
<pre><code class="lang-sql">  -- &#x5C06;lamp138&#x5E93;&#x5BFC;&#x51FA;
  D:\&gt;mysqldump -u root -p lamp138 &gt;lamp138.sql
  Enter password:
  ---- &#x5C06;lamp138&#x5E93;&#x4E2D;&#x7684;stu&#x8868;&#x5BFC;&#x51FA;
  D:\&gt;mysqldump -u root -p lamp138 stu &gt;lamp138_stu.sql
  Enter password:
</code></pre>
</li>
<li><h3 id="&#x6570;&#x636E;&#x5BFC;&#x5165;">&#x6570;&#x636E;&#x5BFC;&#x5165;</h3>
<pre><code class="lang-sql">  -- &#x5C06;lamp138&#x5E93;&#x5BFC;&#x5165;
  D:\&gt;mysql -u root -p lamp138&lt;lamp138.sql
  Enter password:
  -- &#x5C06;lamp138&#x5E93;&#x4E2D;stu&#x8868;&#x5BFC;&#x5165;
  D:\&gt;mysql -u root -p lamp138&lt;lamp138_stu.sql
  Enter password:
</code></pre>
</li>
<li><h3 id="&#x6388;&#x6743;">&#x6388;&#x6743;</h3>
</li>
</ul>
<pre><code class="lang-sql">&#x683C;&#x5F0F;&#xFF1A;grant &#x5141;&#x8BB8;&#x64CD;&#x4F5C; on &#x5E93;&#x540D;.&#x8868;&#x540D; to &#x8D26;&#x53F7;@&#x6765;&#x6E90; identified by &apos;&#x5BC6;&#x7801;&apos;;


--&#x5B9E;&#x4F8B;&#xFF1A;&#x521B;&#x5EFA;zhangsan&#x8D26;&#x53F7;&#xFF0C;&#x5BC6;&#x7801;123&#xFF0C;&#x6388;&#x6743;lamp61&#x5E93;&#x4E0B;&#x6240;&#x6709;&#x8868;&#x7684;&#x589E;/&#x5220;/&#x6539;/&#x67E5;&#x6570;&#x636E;,&#x6765;&#x6E90;&#x5730;&#x4E0D;&#x9650;
mysql&gt; grant select,insert,update,delete on lamp61.* to zhangsan@&apos;%&apos; identified by &apos;123&apos;;
mysql&gt; grant all on *.* to zhangsan@&apos;%&apos; identified by &apos;123&apos;;
Query OK, 0 rows affected (0.00 sec)

&#x200B;&#x6DFB;&#x52A0;&#x7528;&#x6237;, &#x5E76;&#x6388;&#x4E88;&#x5728;lamp189&#x7684;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x53EF;&#x4EE5;&#x5BF9;user&#x8868;&#x8FDB;&#x884C; &#x67E5;&#x8BE2;&#x548C;&#x6DFB;&#x52A0;&#x6570;&#x636E;&#x64CD;&#x4F5C;
&#x200B;GRANT select,insert ON lamp189.user TO &apos;xxoo&apos;@&apos;%&apos; IDENTIFIED BY &apos;abcd&apos;

&#x200B;&#x5220;&#x9664;&#x7528;&#x6237;
&#x200B;drop user &apos;xxoo&apos;@&apos;%&apos;
</code></pre>
<h1 id="mysql&#x5FD8;&#x8BB0;root&#x5BC6;&#x7801;">MySQL&#x5FD8;&#x8BB0;root&#x5BC6;&#x7801;</h1>
<ul>
<li><h3 id="windows">windows</h3>
<pre><code class="lang-sql">      1. &#x7ED3;&#x675F;&#x6B63;&#x5728;&#x8FD0;&#x884C;&#x7684;&#x6570;&#x636E;&#x5E93;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x7A0B; mysqld.exe
  &#x200B;    2. &#x5728;DOS&#x547D;&#x4EE4;&#x884C;&#x6267;&#x884C; mysqld <span class="hljs-comment">--skip-grant-tables</span>
  &#x200B;    3. &#x518D;&#x6253;&#x5F00;&#x4E00;&#x4E2A;DOS&#x7A97;&#x53E3;, &#x53EF;&#x76F4;&#x63A5;&#x8F93;&#x5165; mysql &#x4EE5;&#x7BA1;&#x7406;&#x5458;&#x7684;&#x8EAB;&#x4EFD;&#x5F3A;&#x884C;&#x8FDB;&#x5165;
  &#x200B;    4. <span class="hljs-operator"><span class="hljs-keyword">use</span> mysql
  &#x200B;    <span class="hljs-number">5.</span> <span class="hljs-keyword">update</span> <span class="hljs-keyword">user</span> <span class="hljs-keyword">set</span> authentication_string=<span class="hljs-keyword">password</span>(<span class="hljs-string">&apos;&#x65B0;&#x5BC6;&#x7801;&apos;</span>) <span class="hljs-keyword">where</span> <span class="hljs-keyword">user</span>=<span class="hljs-string">&apos;root&apos;</span>;</span>
  &#x200B;    6. &#x5237;&#x65B0;&#x6743;&#x9650; <span class="hljs-operator"><span class="hljs-keyword">flush</span> <span class="hljs-keyword">privileges</span>;</span>
</code></pre>
</li>
<li><h3 id="ubuntu-1604-lts">Ubuntu 16.04 LTS</h3>
</li>
</ul>
<pre><code class="lang-sql">    -- ubuntu &#x4E0B;, mysql&#x5FD8;&#x8BB0;&#x5BC6;&#x7801;&#x540E;&#x91CD;&#x7F6E;mysql&#x5BC6;&#x7801;

    -- &#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;
    sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

    &#x5728;[mysqld]&#x7684;&#x6BB5;&#x4E2D;&#x52A0;&#x4E0A;&#x4E00;&#x53E5;&#xFF1A;skip-grant-tables &#x4FDD;&#x5B58;&#x5E76;&#x4E14;&#x9000;&#x51FA;vim&#x3002;


    -- &#x91CD;&#x542F;mysqld
    sudo /etc/init.d/mysqld restart


    -- &#x767B;&#x5F55;&#x5E76;&#x4FEE;&#x6539;MySQL&#x7684;root&#x5BC6;&#x7801;
    mysql
    mysql&gt; USE mysql ; 
    mysql&gt; update mysql.user set authentication_string=password(&apos;abc123&apos;) where user=&apos;root&apos; and Host = &apos;localhost&apos;;
    mysql&gt; flush privileges ; 
    mysql&gt; quit


    -- &#x91CD;&#x65B0;&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6; &#x628A;&#x521A;&#x624D;&#x6DFB;&#x52A0;&#x7684;&#x4E00;&#x53E5;&#x6CE8;&#x91CA;&#x6216;&#x8005;&#x5220;&#x9664;
    sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

    -- &#x91CD;&#x65B0;&#x542F;&#x52A8;&#x670D;&#x52A1;
    sudo /etc/init.d/mysqld restart

    -- &#x4F7F;&#x7528;&#x65B0;&#x5BC6;&#x7801;&#x91CD;&#x65B0;&#x767B;&#x5F55;mysql
    mysql -u root -pabc123
    mysql&gt;
</code></pre>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../home/part1/5.DQL操作：数据查询.html" class="navigation navigation-prev " aria-label="Previous page: DQL操作：数据查询"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../home/part2/MySQL高级.html" class="navigation navigation-next " aria-label="Next page: MySQL高级"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
